<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('type')->default(0)->comment('用户类型 0： 普通用户；1：后台用户');
            $table->string('name')->nullable()->unique()->comment('用户名称 用户账号；可用以登录');
            $table->string('nickname')->nullable()->comment('用户昵称');
            $table->string('realname')->nullable()->comment('真实姓名');
            $table->string('email')->unique()->nullable()->comment('用户电子邮箱地址');
            $table->string('mobile')->nullable()->comment('用户手机号');
            $table->string('identity_card')->nullable()->comment('身份证号码');
            $table->string('avatar')->nullable()->comment('用户头像');
            $table->float('balance', 10, 2)->default(0)->comment('账户余额');
            $table->string('province_code', 10)->nullable()->comment('省');
            $table->string('city_code', 10)->nullable()->comment('市');
            $table->string('district_code', 10)->nullable()->comment('区');
            $table->string('address')->nullable()->comment('详细地址');
            $table->integer('sex')->nullable()->default(0)->comment('值为1时是男性，值为2时是女性，值为0时是未知');
            $table->string('password');
            $table->boolean('is_effect')->default(true)->comment('账户是否有效');
            $table->string('source')->default('web')->comment('注册来源 web:网页 weixin：微信 alipay: 支付宝 app：手机客户端');
            $table->timestamp('last_login_at')->nullbale()->comment('最后登录时间');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
